import requests

url = "https://www.baidu.com/"
user_agent = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
}
res = requests.get(url,headers=user_agent)
with open("baidu.html","w",encoding="utf-8") as fp:
    fp.write(res.text)